﻿<phoneNavigation:PhoneApplicationPage 
    x:Class="OneBusAway.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phoneNavigation="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Navigation"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}" xmlns:wp="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls">

    <Grid Background="{StaticResource PhoneBackgroundBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="auto" />
        </Grid.RowDefinitions>

        <!-- title -->
        <TextBlock Text="ONE BUS AWAY" x:Name="textBlockPageTitle" Style="{StaticResource PhoneTextPageTitle1Style}" />

        <!-- content -->
        <StackPanel x:Name="StopTab" Grid.Row="1">

            <TextBlock Text="{Binding SelectedStop.Name}" Style="{StaticResource PhoneTextSubtleStyle}" HorizontalAlignment="Center" />
            <TextBlock Text="{Binding SelectedStop.Code}" Style="{StaticResource PhoneTextSubtleStyle}" HorizontalAlignment="Center" />

            <ListBox ItemsSource="{Binding StopCurrent.ArrivalsAndDepartures}" Style="{StaticResource PhoneListBox}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="auto" />
                                <RowDefinition Height="auto" />
                            </Grid.RowDefinitions>

                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="auto" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="auto" />
                            </Grid.ColumnDefinitions>

                            <TextBlock Text="{Binding RouteShortName}" FontSize="{StaticResource PhoneFontSizeLarge}" Grid.Column="0" Grid.RowSpan="2" VerticalAlignment="Center" />

                            <TextBlock Text="{Binding TripHeadsign}" Grid.Column="1" HorizontalAlignment="Center" />
                            <TextBlock Text="{Binding PredictedDepartureTime}" Grid.Column="1" Grid.Row="1" HorizontalAlignment="Center" />

                            <TextBlock Text="{Binding MinutesUntilDeparture}" FontSize="{StaticResource PhoneFontSizeLarge}" Grid.Column="2" Grid.RowSpan="2"  VerticalAlignment="Center" />

                        </Grid>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </StackPanel>

        <StackPanel x:Name="LocalTab" Grid.Row="1" Visibility="Collapsed">
            <TextBlock Text="{Binding Geo.Status}" />
            <TextBlock Text="{Binding Geo.Position.Location.Latitude}" />
            <TextBlock Text="{Binding Geo.Position.Location.Longitude}" />

            <ListBox ItemsSource="{Binding LocalStops}" Style="{StaticResource PhoneListBox}" Height="680" 
                     SelectionMode="Single" SelectedItem="{Binding SelectedStop, Mode=TwoWay}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="auto" />
                                <RowDefinition Height="auto" />
                            </Grid.RowDefinitions>

                            <TextBlock Text="{Binding Name}" />
                            <StackPanel Orientation="Horizontal" Grid.Row="1">
                                <TextBlock Text="#" />
                                <TextBlock Text="{Binding Code}" />
                                <TextBlock Text=" - " />
                                <TextBlock Text="{Binding Direction}" />
                                <TextBlock Text=" Bound" />
                            </StackPanel>
                        </Grid>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </StackPanel>

        <!-- action bar -->
        <StackPanel Orientation="Horizontal" Grid.Row="2">
            <Button Click="ShowLocalTab" Content="Local" Style="{StaticResource PhoneButtonBase}" />
            <Button Content="Faves" Style="{StaticResource PhoneButtonBase}" />
        </StackPanel>

    </Grid>

</phoneNavigation:PhoneApplicationPage>